package com.csii.pos.rpc;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.csii.adhoc.util.ConvertUtils;
import com.csii.adhoc.util.myabtisplus.QueryWrapperUtils;
import com.csii.adhoc.controller.BaseController;
import com.csii.pos.dto.demo.DemoReq;
import com.csii.pos.dto.demo.DemoRes;
import com.csii.pos.service.demo.DemoService;
import com.csii.pos.sysparam.SysParam;
import com.csii.pos.sysparam.service.ISysParamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @Description: RPC对外demo
 * @Author: PCJ
 * @Date:   2021-07-06
 * @Version: V1.0
 */

@RestController
@Slf4j
public class DemoController extends BaseController<SysParam, ISysParamService> implements DemoService {
    @Autowired
    private ISysParamService sysParamService;

    /**
     * 分页列表查询
     * @param sysParamVO 参数
     * @return 分页结构
     */
    @Override
    public DemoRes queryParamList(DemoReq sysParamVO) {
        SysParam sysParam  = ConvertUtils.convert(SysParam.class,sysParamVO);
        QueryWrapper<SysParam> queryWrapper = QueryWrapperUtils.getEqQueryWrapperFromDto(sysParam, new QueryWrapper<>());
        List<SysParam> list = sysParamService.list(queryWrapper);
        DemoRes demoRes = new DemoRes();
        demoRes.setCode("200");
        demoRes.setData(list);
        return  demoRes;
    }

}
